package brad.zimmerman.dungeon.game;

import android.graphics.PointF;

public class ClassMoveZoom {
	private boolean zoomed;
	int tiles;
	PointF player, scope;
	ClassMoveZoom(int tiles, int X, int Y){
		zoomed = false;
		player = new PointF();
		scope = new PointF();
		player.x = X;
		player.y = Y;
		configureCenter();
		this.tiles = tiles;
	}
	public void configureCenter(){
		if ((player.x) < 5){
			scope.x = 5;
		}
		else if ((player.x) > tiles-5){
			scope.x = tiles-5;
		}else{
			scope.x = player.x;
		}
		if ((player.y) < 5){
			scope.y = 5;
		}
		else if ((player.y) > tiles-5){
			scope.y = tiles-5;
		}else{
			scope.y = player.y;
		}
	}
	public void configureCenter(PointF move){
		if ((move.x) < 5){
			scope.x = 5;
		}
		else if ((move.x) > tiles-5){
			scope.x = tiles-5;
		}else{
			scope.x = move.x;
		}
		if ((move.y) < 5){
			scope.y = 5;
		}
		else if ((move.y) > tiles-5){
			scope.y = tiles-5;
		}else{
			scope.y = move.y;
		}
	}
	public void zoomIntoMatrix(){
		zoomed = !zoomed;
	}
	public boolean getZoom(){
		return zoomed;
	}
	public int zoomScale(){
		if (zoomed){
			return 2;
		}else{
			return 1;
		}
	}
	public int adjustZoomBoundries(int dot, int constant, int width){
		if(zoomed){
			return (dot * constant) + constant/2;
		}else{
			return (dot * (((20*width)/21)/tiles)) + width/21;
		}
	}
	public int adjustZoomBoundriesText(int dot, int constant, int width){
		if(zoomed){
			return (dot * constant) + (constant/2)*3;
		}else{
			return (dot * (((20*width)/21)/tiles)) + (width/21) + (((20*width)/21)/tiles);
		}
	}
	public int zoomedX(){
		if (zoomed){
			return 12;
		}else{
			return 7;
		}
	}
	
	
	//This is where the player is at
	//The map will zoom in on this position
	//so that the player and objects can be
	//seen easier
	public void setPlayerPos(int X, int Y){
		player.x = X;
		player.y = Y;
		configureCenter();
	}
	public int returnLowerX(){
		if(zoomed){
			//return (int) (scope.x + orientation.x - 4);
			return (int) (scope.x - 5);
			}else{
				return 0;
		}
		
	}
	public int returnLowerY(){
		if (zoomed){
			return (int) (scope.y - 5);
		}else{
			return 0;
		}
	}
	public int returnUpperX(){
		if (zoomed){
			return (int) (scope.x + 5);
		}else{
			return tiles;
		}
	}
	public int returnUpperY(){
		if (zoomed){
			return (int) (scope.y + 5);
			
		}else{
			return tiles;
		}
	}
	public int translateX(int X,int Y){
		if (zoomed){
		if (returnLowerX()<=X && X<=returnUpperX() && returnLowerY()<=Y && Y<=returnUpperY()){
			return X-returnLowerX();
		}
		return -1;
		}else{
			return X;
		}
	}
	public int translateY(int X,int Y){
		if (zoomed){
		if (returnLowerX()<=X && X<=returnUpperX() && returnLowerY()<=Y && Y<=returnUpperY()){
			return Y-returnLowerY();
		}
		return -1;
		}else{
			return Y;
		}
	}
}
